package com.lin.manager.secure.controller;

import com.lin.manager.secure.config.properties.SecurityProperties;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @作者: 林江
 * @创建时间: 2024/3/15
 * @功能:
 */
@Controller
public class LoginController {
    @Resource
    private SecurityProperties properties;
    private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();

    @RequestMapping(value = "/login", method = {RequestMethod.GET, RequestMethod.POST})
    public void login(HttpServletRequest request, HttpServletResponse response) throws IOException {
        this.redirectStrategy.sendRedirect(request, response, properties.getRedirect());
    }
}
